ampproject / ampproject/worker-dom

Type specificity in API parameters

Open
#317 0 comments 0 reactions 0 assignees View on GitHub
API
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

Open the contributing 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.