-
Notifications
You must be signed in to change notification settings - Fork 12.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TS5.5-beta injects a random @ts-expect-error
comment in the generated .d.ts
files
#58698
Comments
2 tasks
I tried using A simple reproduction that doesn't take 20s to run TS is:
packages/babel-parser/tsconfig.json{
"extends": "../../tsconfig.base.json",
"include": ["./src/**/*.ts"],
"compilerOptions": {
"rootDir": ".",
"declarationDir": "./dts-parser"
}
} packages/babel-parser/src/globals.d.tsdeclare module "@babel/helper-validator-identifier" {
export function isReservedWord(word: string, inModule: boolean): boolean;
export function isStrictReservedWord(
word: string,
inModule: boolean,
): boolean;
export function isStrictBindOnlyReservedWord(word: string): boolean;
export function isStrictBindReservedWord(
word: string,
inModule: boolean,
): boolean;
export function isKeyword(word: string): boolean;
export function isIdentifierStart(code: number): boolean;
export function isIdentifierChar(code: number): boolean;
export function isIdentifierName(name: string): boolean;
}
declare module "@babel/helper-string-parser" {
export type StringContentsErrorHandlers = EscapedCharErrorHandlers & {
unterminated(
initialPos: number,
initialLineStart: number,
initialCurLine: number,
): void;
};
export function readStringContents(
type: "single" | "double" | "template",
input: string,
pos: number,
lineStart: number,
curLine: number,
errors: StringContentsErrorHandlers,
):
| {
pos: number;
str: string;
firstInvalidLoc: { pos: number; lineStart: number; curLine: number };
lineStart: number;
curLine: number;
containsInvalid?: undefined;
}
| {
pos: number;
str: string;
firstInvalidLoc: { pos: number; lineStart: number; curLine: number };
lineStart: number;
curLine: number;
containsInvalid: boolean;
};
type EscapedCharErrorHandlers = HexCharErrorHandlers &
CodePointErrorHandlers & {
strictNumericEscape(
pos: number,
lineStart: number,
curLine: number,
): void;
};
type HexCharErrorHandlers = IntErrorHandlers & {
invalidEscapeSequence(
pos: number,
lineStart: number,
curLine: number,
): void;
};
export type IntErrorHandlers = {
numericSeparatorInEscapeSequence(
pos: number,
lineStart: number,
curLine: number,
): void;
unexpectedNumericSeparator(
pos: number,
lineStart: number,
curLine: number,
): void;
invalidDigit(
pos: number,
lineStart: number,
curLine: number,
radix: number,
): boolean;
};
export function readInt(
input: string,
pos: number,
lineStart: number,
curLine: number,
radix: number,
len: number | undefined,
forceLen: boolean,
allowNumSeparator: boolean | "bail",
errors: IntErrorHandlers,
bailOnError: boolean,
): {
n: number;
pos: number;
};
export type CodePointErrorHandlers = HexCharErrorHandlers & {
invalidCodePoint(pos: number, lineStart: number, curLine: number): void;
};
export function readCodePoint(
input: string,
pos: number,
lineStart: number,
curLine: number,
throwOnInvalid: boolean,
errors: CodePointErrorHandlers,
): {
code: number;
pos: number;
};
} |
Investigating this I found:
return result === node ? setTextRange(context, factory.cloneNode(result), node) : result;
|
Self contained way to reproduce: Workbench |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
π Search Terms
comment 5.5 invalid injected inlined
π Version & Regression Information
β― Playground Link
No response
π» Code
yarn
to install all depsmake generate-tsconfig
to generate all thetsconfig.json
filesyarn tsc -b ./packages/babel-helper-plugin-utils/tsconfig.json
If you ever need to reset the TS state (e.g. delete all
.tsbuildinfo
and.d.ts
files), runmake clean-dts
.π Actual behavior
dts/packages/babel-parser/src/plugins/typescript/index.d.ts
, line 540 contains a random@ts-expect-error
comment:That
parseExprListItem
is inlined there from another file, that doesn't have that comment:https://github.com/nicolo-ribaudo/babel/blob/e5726bde94899149d60706698a0f0a968208bf60/packages/babel-parser/src/parser/expression.ts#L2711-L2728
Instead, that comment is coming from
https://github.com/nicolo-ribaudo/babel/blob/e5726bde94899149d60706698a0f0a968208bf60/packages/babel-parser/src/plugins/typescript/index.ts#L2637-L2642
π Expected behavior
The comment shouldn't be there
The text was updated successfully, but these errors were encountered: