-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Closed
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser
Description
Bug Report
Current Behavior
Some const assertions result in errors. Seems like the check introduced in this PR is too strict? Because I didn't see any errors in VSCode till I started webpack dev server.
Input Code
function foo() {
const a = getObjectAWithLongAssType();
const b = getObjectBWithLongAssType();
return [a, b] as const; // no errors in tsc or vscode
// Previously: return [a,b] as [typeof a, typeof b]
}
Expected behavior/code
VSCode outputs the expected readonly tuple type, so I don't expect any errors in babel.
Babel Configuration (.babelrc, package.json, cli command)
"@babel/core": "^7.4.0",
"@babel/plugin-proposal-class-properties": "^7.4.0",
"@babel/polyfill": "^7.4.0",
"@babel/preset-env": "^7.4.2",
"@babel/preset-react": "^7.0.0",
"@babel/preset-typescript": "^7.3.3",
Possible Solution
@tanhauhau is there a need for tsCheckLiteralForConstantContext
to happen in babel? To me it seems like it's enough to parse as const
expressions as assertions and move on, since TypeScript is actually in charge of ensuring the assertions are valid.
Hotell, clentfort, gilbert and illusionalsagacity
Metadata
Metadata
Assignees
Labels
area: typescriptoutdatedA closed issue/PR that is archived due to age. Recommended to make a new issueA closed issue/PR that is archived due to age. Recommended to make a new issuepkg: parser