ampproject / ampproject/worker-dom
Type specificity in API parameters
- Dominant language
- TypeScript
- Stars
- 3.3k
- Forks
- 154
- PR merge metrics
- No merged PRs in 30d
Description
We may be too optimistic in ignoring JS vs. TS typing issues in APIs, e.g.
```ts
// Element.ts
public setAttribute(name: string, value: string): void {...}
```
In this example, there's no type conversion if a caller passes in a number or other non-string type.
```js
const el = document.createElement('p');
el.setAttribute('data-foo', 123);
el.getAttribute('data-foo'); // Expected: "123", actual: 123.
```
Contributor guide
Research direction
Start in Element.ts at setAttribute and trace how its value reaches getAttribute. Compare the TypeScript declaration with the JavaScript runtime behavior shown in the issue, then identify the API cases that need consistent type handling. Done means non-string input produces the expected string value without breaking the existing API behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100