feat(isolated-declarations): infer undefined as any type#3798
feat(isolated-declarations): infer undefined as any type#3798
Conversation
Your org has enabled the Graphite merge queue for merging into mainAdd the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix. You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link. |
|
This stack of pull requests is managed by Graphite. Learn more about stacking. |
CodSpeed Performance ReportMerging #3798 will not alter performanceComparing Summary
|
|
|
Thank you for noticing us. We are conforming against https://github.com/microsoft/TypeScript/tree/main/tests/cases/transpile so we will just port bugs if they occur (because we don't really understand the underlying logic). We will correct this once upstream is fixed. |
|
Ah, you're testing this with strict off; // @declaration: true
// @target: es6
// @strict: true
const a = undefined;
using d = undefined;
function c(p = undefined): void {}//// [declarationUndefined.ts] ////
const a = undefined;
using d = undefined;
function c(p = undefined): void {}
//// [declarationUndefined.d.ts] ////
declare const a: undefined;
declare const d: undefined;
declare function c(p?: undefined): void;I would likely be copying the code over as-is; not sure why we don't, so that's its own problem. |
|
@Dunqing Let's gather a few cases where the playground and the |
The API document doesn't mention |
|
That comment only shows the compiler options which differ from the defaults ("If no options are provided - it will use a set of default compiler options."). strictNullChecks is disabled by default (unfortunately). You should pull compiler options from the resolved tsconfig that would be used to compile the code normally via tsc/tsserver/etc. |
Thank you for explaining this. Unfortunately, we're not going to read tsconfig.json yet. |
|
I think for now we just need to be consistent with the default configuration of |
a6a80c2 to
ccb7b52
Compare
|
I think you'd be better off assuming strict=true, if anything. |
|
If you write "undefined" to the output, then non-strict consumers will still get it right. Definitely don't write out any... |
Ok, I agree. FYL: The strict in tsconfig.json created by |

In the TypeScript Playground, it is inferred as the
undefinedtype, but intranspileDeclaration, it is inferred as theanytype. We should make sure that the output is the same as transpileDeclaration's. See: microsoft/TypeScript#58912 (comment)