Skip to content

HTMLScriptElement and HTMLStyleElement type definition does not allow to specify "nonce" attribute #24205

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

Closed
DethAriel opened this issue May 17, 2018 · 1 comment
Assignees
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this

Comments

@DethAriel
Copy link

DethAriel commented May 17, 2018

According to this MDN page, "nonce" is a valid attribute for a <script> element.
This page says the same about <style> element.

TypeScript Version: 2.9.0-dev.20180516

Search Terms:

Code

declare var scriptElement: HTMLScriptElement;
declare var styleElement: HTMLStyleElement;
scriptElement.nonce = "someValue";
styleElement.nonce = "someValue";

A fully-functional local example can be created like this (verified on MacOS):

mkdir nonce-test
cd nonce-test/
yarn init -p -y
yarn add typescript@next

touch test.ts
echo 'declare var scriptElement: HTMLScriptElement;' >> test.ts
echo 'declare var styleElement: HTMLStyleElement;' >> test.ts
echo 'scriptElement.nonce = "someValue";' >> test.ts
echo 'styleElement.nonce = "someValue";' >> test.ts

yarn tsc test.ts --target ES6 --noEmit 

Expected behavior:

the command

tsc test.ts --target ES6 --noEmit 

should complete without errors

Actual behavior:

There are two errors reported:

test.ts:3:15 - error TS2339: Property 'nonce' does not exist on type 'HTMLScriptElement'.

3 scriptElement.nonce = "someValue";
                ~~~~~


test.ts:4:14 - error TS2339: Property 'nonce' does not exist on type 'HTMLStyleElement'.

4 styleElement.nonce = "someValue";
               ~~~~~


Playground Link:
http://www.typescriptlang.org/play/index.html#src=declare%20var%20scriptElement%3A%20HTMLScriptElement%3B%0D%0Adeclare%20var%20styleElement%3A%20HTMLStyleElement%3B%0D%0AscriptElement.nonce%20%3D%20%22someValue%22%3B%0D%0AstyleElement.nonce%20%3D%20%22someValue%22%3B

Related Issues:

Although issue #8955 and pr #8956 are not related to this particular issue, they deal with a very similar problem of having incomplete typings

@mhegazy mhegazy added Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Help Wanted You can do this labels May 17, 2018
@mhegazy mhegazy added this to the Community milestone May 17, 2018
@mhegazy
Copy link
Contributor

mhegazy commented May 17, 2018

PRs welcomed. You can find more information about contributing lib.d.ts fixes at https://github.com/Microsoft/TypeScript/blob/master/CONTRIBUTING.md#contributing-libdts-fixes.

@mhegazy mhegazy modified the milestones: Community, TypeScript 3.0 Jun 19, 2018
@mhegazy mhegazy self-assigned this Jun 19, 2018
@mhegazy mhegazy added the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Jun 19, 2018
@mhegazy mhegazy closed this as completed Jun 19, 2018
@mhegazy mhegazy reopened this Jun 19, 2018
@mhegazy mhegazy modified the milestones: TypeScript 3.0, TypeScript 3.1 Jul 3, 2018
@mhegazy mhegazy added Fixed A PR has been merged for this issue and removed Fixed A PR has been merged for this issue labels Jul 25, 2018
@mhegazy mhegazy removed the Fixed in TSJS repo Fix merged in https://github.com/Microsoft/TSJS-lib-generator, but not ported yet label Jul 31, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Domain: lib.d.ts The issue relates to the different libraries shipped with TypeScript Fixed A PR has been merged for this issue Help Wanted You can do this
Projects
None yet
Development

No branches or pull requests

2 participants