-
-
Notifications
You must be signed in to change notification settings - Fork 120
Closed
Description
Is this a regression?
No
Description
Expected Behavior:
The following
const fields = {
contactEmail: randEmail(),
contactFirstName: randFirstName(),
contactLastName: randLastName(),
};
should report return values of
const fields = {
contactEmail: string,
contactFirstName: string,
contactLastName: string
};
Current behavior:
The above functions result in reporting
const fields = {
contactEmail: string[],
contactFirstName: string[],
contactLastName: string[]
};
Suggested fix:
declare function rand*<Options extends FakeOptions = undefined>(options?: Options): Options["length"] extends number ? string[] : string;
instead of
declare function rand*<Options extends FakeOptions>(options?: Options): Options["length"] extends number ? string[] : string;
Please provide a link to a minimal reproduction of the bug
No response
Please provide the exception or error you saw
The issue simply has to do with that the type seems to favor the left-hand side of the type argument.
Please provide the environment you discovered this bug in
tsconfig: {
"compilerOptions": {
"module": "commonjs",
"declaration": true,
"removeComments": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "es2017",
"sourceMap": true,
"outDir": "./dist",
"baseUrl": "./",
"incremental": true,
"skipLibCheck": true,
"strictNullChecks": false,
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false,
"esModuleInterop": true
}
}
Webstorm 2021.3
VSCode 1.63.2
Anything else?
For some reason, the error does not present itself when run in Code Sandbox with the same tsconfig. However, it has presented itself in two IDE with the above tsconfig.
Do you want to create a pull request?
No
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels