Skip to content
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

fix: re-run typescript without jsx on babel parsing error #849

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

simllll
Copy link
Contributor

@simllll simllll commented Nov 13, 2023

otherwise it breaks parsing some typescript files,

e.g like

public async createFeatureAdvertisement(
		newAdvertisement: IFeatureAdvertisementDTO
	): Promise<FeatureAdvertisement> {
		await this.validateAdvertisementInput(newAdvertisement);

		return this.featureAdvertisementRepository.createFeatureAdvertisement(
			<FeatureAdvertisement>newAdvertisement <-- this is the line that the jsx plugin seems to let typescript fail.
		);
	}

will throw:

parseTypescript /home/simon/Dev/hokify/hokify/libs/feature-advertisement/src/FeatureAdvertisementService.ts SyntaxError: Unexpected token (32:2)
    at instantiate (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:63:32)
    at constructor (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:358:12)
    at TypeScriptParserMixin.raise (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:3255:19)
    at TypeScriptParserMixin.unexpected (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:3285:16)
    at TypeScriptParserMixin.parseExprAtom (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:11284:16)
    at TypeScriptParserMixin.parseExprAtom (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:6974:20)
    at TypeScriptParserMixin.parseExprSubscripts (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:10890:23)
    at TypeScriptParserMixin.parseUpdate (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:10873:21)
    at TypeScriptParserMixin.parseMaybeUnary (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:10849:23)
    at TypeScriptParserMixin.parseMaybeUnary (/home/simon/Dev/hokify/hokify/node_modules/.pnpm/@babel+parser@7.22.7/node_modules/@babel/parser/lib/index.js:9738:18) {
  code: 'BABEL_PARSER_SYNTAX_ERROR',
  reasonCode: 'UnexpectedToken',
  loc: Position { line: 32, column: 2, index: 1079 },
  pos: [Getter/Setter]
}

and therefore cannot parse the whole file. But as I've seen tihs causes some tests to fail, the better appraoch is to re-run it without jsx instead.

@simllll simllll changed the title fix: typescript not using jsx fix: re-run typescript without jsx on babel parsing error Nov 13, 2023
@znarf
Copy link
Collaborator

znarf commented Nov 16, 2023

Similar to #807

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants